/*
 *  POJ
 */

/*-------- Includes --------*/
#include <iostream>

using namespace std;

/*-------- Function Prototypes --------*/
int gcd(int a, int b);
int exgcd(int a, int b, int &x, int &y);

/*-------- Main Function --------*/
int main(int argc, char const *argv[])
{
    int a, b;

    while (cin >> a >> b) {
        int x, y;
        cout << "gcd = " << exgcd(a, b, x, y) << endl;
        cout << "x = " << x << ", " << "y = " << y << endl;
    }

    return 0;
}

/*-------- Functions --------*/
int gcd(int a, int b)
{
    if (!b) return a;

    return gcd(b,  a % b);
}

int exgcd(int a, int b, int &x, int &y)
{
    if (!b) {
        x = 1;
        y = 0;
        return a;
    }

    int r = exgcd(b, a % b, y, x);
    y -= a / b * x;

    return r;
}
